#include <iostream>
using namespace std;
#include <stdlib.h>
typedef struct node
{
	int data;
	node *lchild,*rchild;
}BiNode,*BiTree;
void InsertBST(BiTree &T,int goal)
{
	if(T==NULL)
	{
		T=(BiTree)malloc(sizeof(BiNode));
		T->data=goal;
		T->lchild=T->rchild=NULL;
		return;
	}
	if(goal<T->data)
		InsertBST(T->lchild,goal);
	else
		InsertBST(T->rchild,goal);
}
void CreatBST(BiTree &T,int a[],int lenth)
{
	T=NULL;
	int i;
	for(i=0;i<lenth;i++)
		InsertBST(T,a[i]);
}
int count=0,flag=0;
void SearchBST(BiTree T,int goal)
{
	if(T!=NULL)
	{
		count++;
		if(T->data==goal){flag=1;return;}
		if(goal<T->data)
			SearchBST(T->lchild,goal);
		if(goal>T->data)
			SearchBST(T->rchild,goal);
	}
}
int main()
{
	int a[1000],n,i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	BiTree T;
	CreatBST(T,a,n);
	int goal;
	cin>>goal;
	SearchBST(T,goal);
	if(flag)
		cout<<count;
	else
		cout<<-1;
	return 0;
}